import 'package:animal/constant/color.dart';
import 'package:animal/constant/font.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///默认使用AppBar
class AppBarWidget {
  ///默认使用
  static PreferredSize defaultAppBar({
    Widget? leading,
    Widget? title,
    PreferredSizeWidget? bottom,
    double? leadingWidth,
    // 控制下方阴影栏的坐标
    double? elevation,
    double? titleSpacing,
    double toolbarOpacity = 1.0,
    double? appBarHeight,
    bool automaticallyImplyLeading = true,
    bool? centerTitle,
    // appbar是否显示在任务栏顶部
    bool? primary,
    Color? backgroundColor,
    List<Widget>? actions,
    TextStyle? titleTextStyle,
    Color? backColor,
  }) {
    return PreferredSize(
      preferredSize: Size.fromHeight(appBarHeight ?? 56.0),
      child: AppBar(
        leading: automaticallyImplyLeading
            ? leading ??
                GFIconButton(
                    icon: Image.asset(
                      "icons/icon_back.png",
                      width: ScreenUtil().L(25),
                      color: backColor??KColorConstant.black222,
                    ),
                    onPressed: () => Get.back(),
                    type: GFButtonType.transparent)
            : null,
        leadingWidth: leadingWidth ?? kToolbarHeight,
        title: title ?? Container(),
        centerTitle: centerTitle ?? true,
        actions: actions,
        elevation: elevation ?? 4,
        primary: primary ?? true,
        backgroundColor: backgroundColor ?? Colors.blue,
        automaticallyImplyLeading: automaticallyImplyLeading,
        titleSpacing: titleSpacing ?? NavigationToolbar.kMiddleSpacing,
        toolbarOpacity: toolbarOpacity,
        titleTextStyle: titleTextStyle ?? KFontConstant.myTextStyle(size: 18, color: Colors.black, bold: true),
        bottom: bottom,
      ),
    );
  }
}
